import { DefaultFooter, getMenuData, getPageTitle } from '@ant-design/pro-layout';
import { Helmet, HelmetProvider } from 'react-helmet-async';
import { Link, SelectLang,Redirect, useIntl, connect, FormattedMessage } from 'umi';
import React from 'react';
import { GithubOutlined } from '@ant-design/icons';

import logo from '../assets/logo.svg';
import styles from './UserLayout.less';

const UserLayout = (props) => {
  const {
    route = {
      routes: [],
    },
  } = props;
  const { routes = [] } = route;
  const {
    children,
    location = {
      pathname: '',
    },
  } = props;
  const { formatMessage } = useIntl();
  const { breadcrumb } = getMenuData(routes);
  const title = getPageTitle({
    pathname: location.pathname,
    formatMessage,
    breadcrumb,
    ...props,
  });
  const token=localStorage.getItem('token')
  if (token) {
    return <Redirect to={'/dashboard/workplace'}></Redirect>
  }
    return (
      <HelmetProvider>
        <Helmet>
          <title>{title}</title>
          <meta name="description" content={title} />
        </Helmet>
  
        <div className={styles.container}>
          <div className={styles.lang}>
          </div>
          <div className={styles.content}>
            <div className={styles.top}>
              <div className={styles.header}>
                <Link to="/">
                  <img alt="logo" className={styles.logo} src={logo} />
                  <span className={styles.title}>Fun Blog Admin</span>
                </Link>
              </div>
              <div className={styles.desc}>
                <FormattedMessage
                  id="pages.layouts.userLayout.title"
                  defaultMessage="Ant Design 是西湖区最具影响力的 Web 设计规范"
                />
              </div>
            </div>
            {children}
          </div>
          <DefaultFooter
            copyright={`${new Date().getFullYear()} 不知名前端人Kevin出品`}
            links={[
              {
                key: 'Fun Blog Admin',
                title: 'Fun Blog Admin',
                href: 'https://gitee.com/Keivn.vip.com/FunBlogAdmin',
                blankTarget: true,
              },
              {
                key: 'github',
                title: <GithubOutlined />,
                href: 'https://gitee.com/Keivn.vip.com/FunBlogAdmin',
                blankTarget: true,
              },
              {
                key: 'Ant Design',
                title: 'Ant Design',
                href: 'https://ant.design',
                blankTarget: true,
              },
            ]}
          />
        </div>
      </HelmetProvider>
    );
  
  
};

export default connect(({ settings }) => ({ ...settings }))(UserLayout);
